<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function isObject(value){
            return typeof value === 'object' && value !== null
        }
        function reactive(data){
            if(!isObject(data)){
                return data
            }
            return new Proxy(data,{
               get(target,key){
                    return target[key]
               },
               set(target,key,value){
                    target[key] = value
                    return true
               }
            })
        }
        const state={name:'小胖'}
        const p=reactive(state)
        p.name='李四'
        console.log(state)
    </script>
</body>
</html>